#RemoteEvent won't fire
15 messages · Page 1 of 1 (latest)
its all because of this
task.spawn(function()
while true do
local closestPlayer = nil
local closestDistance = math.huge
for _, player in ipairs(game.Players:GetPlayers()) do
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
local distance = (character.HumanoidRootPart.Position - ballPosition).Magnitude
if distance < closestDistance then
closestPlayer = player
closestDistance = distance
end
end
end
if closestPlayer then
local velocity = (closestPlayer.Character.HumanoidRootPart.Position - ballPosition).Unit * speed
ball.Velocity = velocity
end
ballPosition = ball.Position
wait(0.1)
end
end)
blockEvent.OnServerEvent:Connect(function(player)
print(player.Name .. " has triggered the 'Block' event on the server!")
end)```
since spawn() exsited
crazy
but task was not used that much
so what does it print in output
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local BlockEvent = game.ReplicatedStorage.Events.Block
local function onInputBegan(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not gameProcessed then
print("Mouse button 1 clicked")
BlockEvent:FireServer()
print(BlockEvent,'Firing to Server')
end
end
UserInputService.InputBegan:Connect(onInputBegan)```
** You are now Level 3! **