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

Why cant i use fire server from local script in player scripts?

I have this script

--local script-
local UserInputService = game:GetService("UserInputService")

function onKeyPress(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.E then
	game.ReplicatedFirst.Button1:FireServer()	
	end
	end



UserInputService.InputBegan:Connect(onKeyPress)

i have tested this with a print statement inside the if statement on line 5 so it is a correct statement but its not firing the event this is the script in the event

--script--
script.Parent.OnServerEvent:Connect(function()
print("e")
end)

1 answer

✓ Accepted answer

It's in ReplicatedFirst, not ReplicatedStorage.Change the code to game.ReplicatedStorage.Button1:FireServer()

2 comments

0

like you said in chat i needed to move the script to server script service and edit the script

0

like you said in chat i needed to move the script to server script service and edit the script

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