Heya, so this is meant to check and disable/enable a script in the player. It doesn’t seem to be working, can anyone help me out? Thanks!
script.Parent.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
local person = touch.Parent
local player = game.Players:FindFirstChild(person.Name)
if player.SolidMaterial.Disabled == true then
player.SolidMaterial.Disabled = false
player.IceSkating.Disabled = true
else
if player.IceSkating.Disabled == true then
player.IceSkating.Disabled = false
player.SolidMaterial.Disabled = true
end
end
end)
1 Like
I do believe that you’re defining a string
value, instead of the actual Instance of the Character
Model?
Try this:
script.Parent.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
local person = touch.Parent
local player = game.Players:FindFirstChild(person)
if player.SolidMaterial.Disabled == true then
print("On ground")
player.SolidMaterial.Disabled = false
player.IceSkating.Disabled = true
else
if player.IceSkating.Disabled == true then
print("On ice")
player.IceSkating.Disabled = false
player.SolidMaterial.Disabled = true
end
end
end)
1 Like
Heya! Thanks for replying.
It seems to be red underlining the last
end)
As well as this I did mess up my true-false enabled, but it still doesn’t seem to be working. The print functions don’t pop up either, I’m thinking it’s an issue with the last end)
Ooh I see, yeah you need to close all of the end
statements properly which I what I didn’t see
This should be fixed:
local debounce = false
script.Parent.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
local person = touch.Parent
local player = game.Players:GetPlayerFromCharacter(person)
if player.SolidMaterial.Disabled == true then
print("On ground")
player.SolidMaterial.Disabled = false
player.IceSkating.Disabled = true
elseif player.IceSkating.Disabled == true then
print("On ice")
player.IceSkating.Disabled = false
player.SolidMaterial.Disabled = true
end
wait(2)
debounce = false
end
end)
I also went ahead & added a debounce so that the Event doesn’t run multiple times when touched
1 Like
Heya, once again thank you for the help!
Thanks for the debounce also, I’m still very new to scripting.
When the script is run and the player touches the part, this appears in output
13:38:17.759 SolidMaterial is not a valid member of Player “Players.kitkatsncoffee” - Server - Script:8
Nothing seems to be mis spelled. If you could, I would really appreciate help on this!
Hm, where exactly did you put the SolidMaterial
and IceSkating
scripts in? The Player’s Character?
Yep, just in the character model
Replace with
player.Character.SolidMaterial.Disabled
1 Like
Some issues to know about this code:
- The client doesn’t know that the server is disabling the scripts sometimes, which causes the client to completely bypass the disable.
-
Disabled
completely disables the code from executing, meaning it cannot be ran even if it was re-enabled.