local UserInputService = game:GetService("UserInputService")
local debounce = true
local distance = 4
local function key(inputy, typingx)
if typingx then return end
if inputy.KeyCode == Enum.KeyCode.E and (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").Position - game.Workspace.CrateStuff.start.Position).Magnitude <= distance then --requirements
game.ReplicatedStorage.Crate:FireServer(69) --xD
end
end
UserInputService.InputBegan:Connect(key)
I have tried to change it up with OnClientEvent and FireAllClients()
I am not asking for entire scripts, I am asking for help with the script I’ve provided above. I DO NOT want to be spoon-fed answers.
The Connect method only accepts one parameter a function,if you need those other strings you have in the connect function you need to store them in variables, you need to do:
FireAllClients is used to communicate with every player in the game, on their individual client. FireClient is used for just one client. I’m talking about when you do OnServerEvent, the first parameter is the player object, and then you can define your arguments.
Server:
(Keep in mind that firing remote event from client to server ALWAYS the first argument is player automatically)
game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent").OnServerEvent:Connect(function(player,hello)
print(player.Name.." said "..hello)
--do your function here
end)