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

I can't get the gui to disable the player's walkspeed while visible?

local player = script.Parent.Parent.Parent.Parent


for i, object in pairs(game.Workspace:GetChildren()) do
	if player.Name == object.Name then
		local char = object
		local human = char:FindFirstChild("Humanoid")
		local walkSpeed = human.WalkSpeed
		if script.Parent.Visible == true then
			walkSpeed = 0
		end
	end
end

1 answer

✓ Accepted answer

When you make a variable equal to an object's property, the variable will become what the property equals, but it won't retain a reference to the object.

So if a part's Transparency is 1, t = part.Transparency will make t equal 1.

t, however, doesn't retain a reference to part, meaning that if I edit t later the transparency of the part won't change.

To fix this, just make your variable equal to the object, then edit its property.

if script.Parent.Visible == true then
	human.WalkSpeed = 0
end

1 comment

0

Thank you so much :D

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