I encountered a problem in my script when i was checking if a player was holding down the Q key have no idea how i can fix this.
Here are my two scripts :
The Client script
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local block = game.Workspace.Part:Clone()
block.Parent = workspace
local Key = 'Q'
local debounce = true
UserInputService.InputBegan:Connect(function(Input ,IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if Input.UserInputType == Enum.UserInputType.Keyboard then
if KeyPressed == Enum.KeyCode[Key]and debounce and character then
game.ReplicatedStorage.FireBallEvent:FireServer(Mouse.Hit, UserInputService, Key)
end
end
end)
The Server Script
local fireball = Instance.new("Part", workspace)
game.ReplicatedStorage.FireBallEvent.OnServerEvent:Connect(function(player, mouse, UserInputService, Key)
while wait(1) do
if UserInputService:IsKeyDown(Enum.KeyCode[Key]) then
print("the fireball is being charged!")
fireball.Size = fireball.Size + Vector3.new(0.01,0.01,0.01)
else
print("the fireball has been fired!")
break;
end
end
end)

5 comments
Why are you using UserInputService on the server?
you cant use
user imput service
on the server side
Because I want others players to see the fireball changing its size.