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

Trying to learn Filtering Enabled, need some help with this?

I just started to learn filtering enabled, and the idea is to create a part in the server when the player presses a key.It works for me in Studio but when I Start a server in studio to see if it actually works with FE on it doesn't work anymore

--This is in a local script.
Player = game:GetService("Players").LocalPlayer
Char = Player.Character
mouse = Player:GetMouse()

mouse.KeyDown:connect(function(key)
	if key == "j" then
		script.Test.JustTesting:FireServer()
	end
end)

--This is a script inside the local script 
Player = game:GetService("Players").LocalPlayer
Char = Player.Character
--JustTesting is a remote event inside the script
script.JustTesting.OnServerEvent:connect(function()
		a = Instance.new("Part", workspace)
		a.CFrame = Char.Torso.CFrame*CFrame.new(0, 0, -10)
end)

Thank you!

3 comments

0

KeyDown is deprecated. Use UserInputService. Also, :connect() is deprecated. Use :Connect(). Also, you are trying to access LocalPlayer from a server script. Also, you never fired the remote event.

0

'script.Test.JustTesting:FireServer()' doesn't this fire it?

0

Nvm it worked thank you a lot! <3

1 answer

✓ Accepted answer

Using the mouse for path access to the keyboard is deprecated, use UserInputService instead.

Also, when communicating between remote events, you can't leave the empty parenthesis hanging, you must send a variable, object, or value through it. If you are only attempting to contact the other server script without needing to place a parameter or value, just place in nil.

Access UserInputService using the method :GetService().

Userinputservice = game:GetService("UserInputService")

For the API link click here.

For examples and a short tutorial click here.

2 comments

0

Thank you a lot for the explanation!

0

You're most welcome!

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