I have changed the script a litle, can you try it out now?
Edit: it won’t work. You need to disconnect the function in order for it to work.
I have changed the script a litle, can you try it out now?
Edit: it won’t work. You need to disconnect the function in order for it to work.
Should I keep it as three separate if
statements, since I have one to detect if the player has the correct tool as well?
After the first two ifs u can add ur logic statement. And if the player doesnt have the required tool, just exit/return.
Lmk if my solution helps.
I did. I will try it again with the updates you made though.
Edit: I added marker.Parent:FindFirstChildWhichIsA("Humanoid")
, and now it won’t enable or disable it at all:
script.Parent.Touched:Connect(function(marker)
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 and marker.Parent:FindFirstChildWhichIsA("Humanoid") then
if not Debounce then
Debounce = true
copy.Enabled = true
copy.ImageButton.LocalScript.Disabled = false
task.wait(5)
if perms then
perms = false
end
end
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 and marker.Parent:FindFirstChildWhichIsA("Humanoid") then
if not Debounce then
Debounce = true
copy.Enabled = false
copy.ImageButton.LocalScript.Disabled = true
task.wait(5)
if perms then
perms = false
else
copy.Enabled = false
copy.ImageButton.LocalScript.Disabled = true
end
script.Parent.TouchEnded:Connect(function()
if copy.Enabled == true then
perms = false
else
perms = true
end
end)
Tell me if I did something wrong.
Sorry but i changed it once more
The problem here was that the function constantly fired.
I have tried it, and like @schaap5347’s script, it wouldn’t enable it even if I had the correct tool and everything.
Script:
local cooldown = os.clock()
script.Parent.Touched:Connect(function(marker)
if not marker.Parent:FindFirstChildWhichIsA("Humanoid") then return end
if os.clock() - cooldown >= 5 then cooldown = os.clock() else return end
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 then
copy.Enabled = true
copy.ImageButton.LocalScript.Disabled = false
task.wait(5)
script.Parent.Touched:Connect(function(marker)
if not marker.Parent:FindFirstChildWhichIsA("Humanoid") then return end
if os.clock() - cooldown >= 5 then cooldown = os.clock() else return end
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 then
copy.Enabled = false
copy.ImageButton.LocalScript.Disabled = true
task.wait(5)
else
copy.Enabled = false
copy.ImageButton.LocalScript.Disabled = true
end
What might have I done wrong?
local cooldown = os.clock()
script.Parent.Touched:Connect(function(marker)
if not marker.Parent:FindFirstChildWhichIsA("Humanoid") then return end
if os.clock() - cooldown >= 5 then cooldown = os.clock() else return end
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 then
if copy.Enabled then
copy.Enabled = false
copy.ImageButton.Localscript.Disabled = true
else
copy.Enabled = true
copy.ImageButton.Localscript.Disabled = false
end
end
I think all the scripts broke the model. Tried the old version which used to work but that doesn’t seem to work now either. No errors as well.
Edit: I’ll try and get rid of all the scripts in the model and get all the old scripts back. Then when I have them back I can try and work this out again.
Sigh what is CardNumber
and how did the above scripts break the model?
The CardNumber
is the specific number in the tool for the SurfaceGui to enable.
Edit: Just realised it doesn’t copy in the player like it should do.
I needed to do stuff so couldnt reply.
The thing is you’re not using my format.
Ight this should be it
script.Parent.Touched:Connect(function(marker)
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 then
if not Debounce then
Debounce = true
if perms then
copy.ImageButton.LocalScript.Disabled = true
copy.Enabled = false
else
copy.Enabled = true
copy.ImageButton.LocalScript.Disabled = false
end
end
Debounce = false
end
end)
script.Parent.TouchEnded:Connect(function()
if copy.Enabled == false then
perms = false
else
perms = true
end
end)
Then thats a problem on ur end.
It was working perfectly fine before, and near where I kept changing it, was where it copies it over in the script. I will try and check what the issue is though.
Maybe it would work better if I keep it in a separate script maybe, LocalScript?
I think I have fixed issue now. The model wasn’t permanently broken, the script was disabled.
However when I still test your script, the SufaceGui doesn’t seem to copy into the PlayerGui, and I think it causes other problems in the script. Might be because of os.clock()
but not sure.
My script isn’t supposed to copy anything, I thot i did it on ur end.
Oh im an idiot sry mb use this script.
local cooldown = os.time()
script.Parent.Touched:Connect(function(marker)
if not marker.Parent:FindFirstChildWhichIsA("Humanoid") then return end
if os.time() - cooldown >= 5 then cooldown = os.time() else return end
if marker ~= nil and marker.Parent ~= nil and marker.Parent:FindFirstChild("CardNumber") ~= nil and marker.Parent.CardNumber.Value == 55 then
if copy.Enabled then
copy.Enabled = false
copy.ImageButton.Localscript.Disabled = true
else
copy.Enabled = true
copy.ImageButton.Localscript.Disabled = false
end
end
Lmk whether this solves the issue.
When I use the original script (which disables the SurfaceGui after a few seconds), I don’t get any errors from any other scripts. When I try your script however, I always get this error from a different LocalScript:
Maybe too many if
statments, but not sure.
Could you show me line 3 of that script?
This is the 3rd line down in the LocalScript, where the error is coming from:
derp.SurfaceGui.Frame.CurrentColor.Changed:Connect(function(val)
What is derp (char limit char).