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

How do i us this code?

I want to be able to step on an object and then press f to make something happen but it wont work. Help please!

if game.Workspace.Part.Touched:connect(function()) then

Player = Game.Players.LocalPlayer Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(key) print(key) end)

1 comment

0

You used an if then statement where you should not have, you should have defined the player, and gotten them from their character, or fired an event to do so... if applicable. You used a local script function in a script, as such player is undefined... you got mouse from something that is nil, you missed 2 ends...

1 answer

✓ Accepted answer

Theres actually a really good tutorial of it on the wiki here: http://wiki.roblox.com/index.php?title=ContextActionService_tutorial You'll want to use ContextActionService (This is double-cool, because you can then use it on Mobile too!) Basically, the tutorial covers this exact question. Give it a read and it should be able to give you some answers :)

1 comment

1

Thanks alot guys. This really helped.

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