Search code examples
robloxroblox-studio

Why is this not activating the script?


So, because I am not a Member of DevForum, I will have to post my Roblox problems onto here.

Alright. I want to make a flood happen when I click a button. But it didn't work.

Here is my code:

local water = game.Workspace["water-flood"]
local iteration = 0
print("script activated")

script.Parent.Activated:Connect(function()
    print("activated")
    while water.Size.Y <= 75 do
        iteration = iteration + 1
        water.Size = Vector3.new(534, iteration * 5, 326)
        print(iteration)
        print(iteration * 5)
        wait(5)
    end
    if water.Size.Y > 75 then
        wait(15)
        print("reload")
    end
end)

I tried printing when something happened (as you can see with all the print()s) but I've noticed something. The print("activated") does not run when I click the button but print("script activated) runs when I start the game. Why is this?


Solution

  • --(Server Script)
    -- (.Activated event doesn't seem to fire with FilteringEnabled)
    local water = game.Workspace["water-flood"]
    print("script activated")
    local floodtime=10
    while script.Parent.MouseButton1Click:Wait()==nil do 
        print("activated")
        game:service"TweenService":Create(water,TweenInfo.new(floodtime),{Size=Vector3.new(water.Size.X,75,water.Size.Z)}):Play()   
        wait(floodtime)
        --wait(15)
        print("reload")
    end