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

i maked a script , like when i press R and anyone then envent:fireserver but idk what's wrong?

local A_1 = "PunchSelf"
local A_2 = 
{
            if input.KeyCode == Enum.KeyCode.R then
    [1] = game:GetService("Workspace").mouse.target
}
local Event = game:GetService("ReplicatedStorage").Events.Compulsion
Event:FireServer(A_1, A_2)

can anyone help me?

1 comment

0

*made

1 answer

https://developer.roblox.com/en-us/api-reference/class/UserInputService

don't know what 'input' is in your script.

when you fire the event, you aren't even using the input thing. You are just firing it right away so pressing r won't do anything.

-- should look more like this. (still wont work)
local userinput = game:GetService'UserInputService'
local Event = game:GetService("ReplicatedStorage").Events.Compulsion
local A_1 = "PunchSelf"
local A_2 = 
{ -- isnt being used anyways. (could just delete)
    [1] = game:GetService("Workspace").mouse.target
}
userinput.inputbegan:Connect(function(input) -- something like this. (makes it fire after r pressed instead of right when the scripts runs.
            if input.KeyCode == Enum.KeyCode.R then
		Event:FireServer(A_1, A_2)

in the server script, it could be something like this

local Event = game:GetService("ReplicatedStorage").Events.Compulsion

Event.OnServerEvent:Connect(function(player, A_1, A_2)
	-- whatever ur event does
end)

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