Disabling not working

i have a double jump script inside starterplayers
and I want to make it enable when touching the wall, then disables it one second later
but when I tested it, its not disabled and when I touched the wall it did nothing.
here’s the script:

local p = game.Players.LocalPlayer
local c = p.Character
c.REEE.disabled = true
script.Parent.Touched:connect(function(Hit)
	
	if p then
		c.REEE.disabled = false
		wait(1)
		c.REEE.disabled = true
	end
	
end)

(I don’t find the script inside my character is that the reason?)
(btw its a local script inside the part does that have to do with anything?

1 Like

if the script is a local script it has to be in ur player or character or else it wont run

1 Like

so do i do it in a normal script?

i would recommend doing it in a normal script, if u need the player you can get the player using game.Players:GetPlayerFromCharacter()

https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter

how would i find the character?

assuming that the script is located inside the part

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
end
end)

2 Likes

hmmm seems like the script don’t exist?

script.Parent.Touched:connect(function(Hit)
	if Hit.Parent:FindFirstChild('Humanoid') then
		local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
		plr.Character.REEE.Disabled = false
		wait(1)
		plr.Character.REEE.Disabled = true
	
end
end)

i have it disabled cause i only want it to be flase when touching the part

so you want the script “REEE” to be disabled while touching the part?

yes, and reabled when 1 second later

you did put a space between Character.REEE so it is Character .REEE instead, that might be the problem

oh wait no sorry its just the spacing between the characters in that font

what is the output error when u touch it

blue line for line 4 says the output
and attemt to index nil with REEE

make sure the server can see the REEE script, u can do so by pressing “Current server” in the home tab i think. Make sure the script also had time to load, try putting :WaitForChild(“REEE”)

it says inf yeild possible with reee and line 5 have problem


script.Parent.Touched:connect(function(Hit)
	if Hit.Parent:FindFirstChild('Humanoid') then
		local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
		local R = plr.Character:WaitForChild("REEE")
		R.Disabled = false
		wait(1)
		R.Disabled = true
	
end
end)

the error is that the script cant find REEE so it has to be either a client script or it has already been deleted

hmm i wonder does disabled = deleted and never be seen again

disabled prevents the script from running and when enabled again it starts from the begging almost like re-executing the script

1 Like
local part = script.Parent

part.Touched:Connect(function(hit)
     local plr = hit.Parent
     local plrs = game.Players:GetPlayerFromCharacter(hit)
     local plrss = plrs:WaitForChild("REEE")
     plrss.disabled = true
     if plrs ~= nil then
     plrss.disabled = false
     wait(1)
     plrss.disabled = true 
    end
end)

20:31:42.589 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:42.589 Stack End - Studio
20:31:42.686 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:42.687 Stack Begin - Studio
20:31:42.687 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:42.687 Stack End - Studio
20:31:42.688 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:42.688 Stack Begin - Studio
20:31:42.688 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:42.688 Stack End - Studio
20:31:42.689 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:42.689 Stack Begin - Studio
20:31:42.690 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:42.690 Stack End - Studio
20:31:42.690 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:42.690 Stack Begin - Studio
20:31:42.690 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:42.690 Stack End - Studio
20:31:43.754 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:43.754 Stack Begin - Studio
20:31:43.754 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:43.755 Stack End - Studio
20:31:44.053 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.054 Stack Begin - Studio
20:31:44.054 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.055 Stack End - Studio
20:31:44.160 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.160 Stack Begin - Studio
20:31:44.160 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.161 Stack End - Studio
20:31:44.822 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.822 Stack Begin - Studio
20:31:44.822 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.823 Stack End - Studio
20:31:44.823 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.823 Stack Begin - Studio
20:31:44.825 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.825 Stack End - Studio
20:31:44.825 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.826 Stack Begin - Studio
20:31:44.826 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.826 Stack End - Studio
20:31:44.826 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.826 Stack Begin - Studio
20:31:44.826 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.827 Stack End - Studio
20:31:44.827 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:44.827 Stack Begin - Studio
20:31:44.827 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:44.827 Stack End - Studio
20:31:47.170 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:47.171 Stack Begin - Studio
20:31:47.171 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:47.171 Stack End - Studio
20:31:47.274 Workspace.Part.Script:6: attempt to index nil with ‘WaitForChild’ - Server - Script:6
20:31:47.274 Stack Begin - Studio
20:31:47.274 Script ‘Workspace.Part.Script’, Line 6 - Studio - Script:6
20:31:47.274 Stack End - Studio