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)
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)
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
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!