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

local script not running in game but in roblox studio solo mode?

Although I Pressed space when the character's head is transparent it did not run in game and when I press space in roblox studio solo mode, it works perfectly without changing the script.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(key)
	if key:byte() == 32 then
		if Player.Character.Head.Transparency == 1 then
			Player.Character.Parent = game.Workspace
		end
	end
end)

8 comments

0

Why are you parenting the character to workspace? It's already in there...

0

I moved the parent to a model in workspace so It would move the location that model moves

0

So you will parent the character to another model in workspace? And you want to check if they're jumping and they have their head transparent?

0

I replaced line 7 with a print function and it worked so it should

0

Answer my question.

0

LocalScripts only run in places that are individual to each player, such as their gui or backpack (not in workspace). If you move the script into StarterGui or some other 'local' place, it should run.

0

This makes no sense. The character model is automatically in Workspace.

0

The character is the only location local scripts can run in in workspace, because each player has their own individual character. Having it in a random part, however, would not tell you who the local script belongs to, and therefore not run it.

1 answer

Hey,

You need UserInputService for detecting keyboards!

1 comment

0

Could've been a comment :s

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