So I watched this youtube tutorial and I followed everything he did, and when it came time to testing nothing worked. I checked the output, and there wasn’t anything wrong. Anyway this is my script:
local uis = game:GetService("UserInputService")
local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local db = false
uis.InputBegan:Connect(function(input, GPE)
if not GPE and not db then
db = true
if input.KeyCode == Enum.KeyCode.M then
re:FireServer()
wait(5)
db = false
end
end
end)
local re = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
re.OnServerEvent:Connect(function(Player)
local character = workspace:WaitForChild(Player.Name)
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
local HaoHaki = game:GetService("ReplicatedStorage"):WaitForChild("HaoHaki")
HaoHaki:Clone()
HaoHaki.Parent = workspace
HaoHaki.CFrame = character.HumanoidRootPart.CFrame
game.Debris:AddItem(HaoHaki, 2)
end)
That is incorrect, InputBegan returns the InputObject as the first parameter and a gameProcessEvent boolean as the 2nd parameter, his issue is most definitely that he makes db true regardless if he pressed M or not, it needs to be in the if input.KeyCode == Enum.KeyCode.M if statement
No.
It contains two arguments the first argument is the input of the player and the second argument is the game processed event(to check interaction with UI).
you can name them whatever you want but remember the first argument taken in by the function is the input and the second argument taken in is counted as the GPE which is returned in either false or true.