Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The script works only once it doesn't say anything in the console?

This is inside a ClickDetector and a normal script. It works only once and when I try to do this a second time it stops working. ~~lua script.Parent.MouseClick:Connect(function(plr)

if plr.PlayerGui:FindFirstChild("Dialog") == nil then

local gui = script.Parent.Dialog:Clone()

plr.Character.Humanoid.WalkSpeed = 0

gui.Parent = plr.PlayerGui

gui.Core.Disabled = false

script.Disabled = true

wait(1)

script.Disabled = false

end

end) ~~

2 comments

0

Well, duh. Since Dialog is cloned into the PlayerGui, it is no longer nil and the function stops working because Dialog is already there.

0

It doesn't work after the dialog has been deleted which is when it has been completed

1 answer

Considering that you didn't delete the dialog from the script you inserted it in, you probably deleted the dialog in a local script. Whenever you do something in a local script, the server blocks that change and the change only happens for the player who activated the local script. In this case, you deleted the dialog in a local script which means that the server script can not see that the dialog is no longer in the player as the server blocket that change. To fix this, I would recommend you to instead use a local script to insert the dialog. This won't cause any problem as the walkspeed of a character is something that you can change from a local script as the server doesn't have to accept the change for it to work.

This discussion is preserved as it was. New answers, comments, and votes are closed.