Hello everyone!
I need some help with respawning a meshpart / tsunami and the movement of it.
So, whenever a player clicks on a textbutton the tsunami will start moving towards the player and will eventually respawn after 15 seconds, but if I click the button again after those 15 seconds the tsunami doesn’t move anymore…
Here’s my scripting:
I used a local script under the textbutton that triggers a remote event ‘Tsunami O1’:
local storage = game.ReplicatedStorage
local button = script.Parent
button.MouseButton1Click:Connect(function()
storage.TsunamiO1:FireServer()
end)
In the ServerScriptService I added a script that enables the ‘Move’ script in the tsunami when the remote event ‘Tsunami O1’ is triggered:
local storage = game.ReplicatedStorage
storage.TsunamiO1.OnServerEvent:Connect(function()
game.Workspace["Tsunami Oranje"]["Tsunami 1"].Move.Enabled = true
end)
Under the previously mentioned textbutton I added another local script that triggers the remote event ‘RespawnO1’ when the button is clicked:
local storage = game.ReplicatedStorage
local button = script.Parent
button.MouseButton1Click:Connect(function()
storage.RespawnO1:FireServer()
end)
I then added a script (‘Respawn O1’) in the ServerScriptService that respawns the tsunami to its original place and disables the ‘Move’ script in the tsunami after 15 seconds when the remote event ‘RespawnO1’ is triggered:
local storage = game.ReplicatedStorage
storage.RespawnO1.OnServerEvent:Connect(function()
wait(15)
game.Workspace["Tsunami Oranje"]["Tsunami 1"].Position = Vector3.new(237.888, 12.275, 288.785)
game.Workspace["Tsunami Oranje"]["Tsunami 1"].Move.Enabled = false
end)
The ‘Move’ script:
local sp = script.Parent.Speed.Value
while true do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0,-sp)
wait()
end
After this, the tsunami is at its original place but when I click the textbutton again to activate the tsunami, the tsunami doesn’t move.
Can anybody help me with this please?
Kind regards