In my game, about Telekentics, the client shoots a ray to grab the looked at object, then reports this to the server to have it throw back with some force.
A little before my issue, it was all working fine, then about 8-10 minutes later after coding a movement system, it appears to have stopped being able to send or receive things from the remoteEvent. this is NOT an issue with the Event itself, as i have replaced it and tried with the new one, made new scripts, left and rejoined my session, and disabled / removed the movement script.
my client side script:
local player = game.Players.LocalPlayer
local event = game.ReplicatedStorage.TelekeneticEvent
local cam = workspace.CurrentCamera
local head = player.Character:WaitForChild("Head")
local UIS = game:GetService("UserInputService")
local COOLDOWN_TIME = 3
local partCooldowns = {}
local function ray(start: Vector3, direction: Vector3)
local r = workspace:Raycast(start, direction)
return r and r.Instance or nil
end
UIS.InputBegan:Connect(function(a, b)
if b or a.KeyCode ~= Enum.KeyCode.E then return end
print("attempting to send!")
local Result = ray(
head.Position,
cam.CFrame.LookVector * 50
)
if not Result then return end
local lastUsed = partCooldowns[Result] or 0
local currentTime = tick()
if currentTime - lastUsed < COOLDOWN_TIME then
-- Part is still on cooldown
return
end
-- Update the part's last used time
partCooldowns[Result] = currentTime
-- Do the normal stuff
game.Debris:AddItem(Instance.new("Highlight", Result), 1.5)
event:FireServer(Result, Result.Position - head.Position)
print("end")
end)
my server side code:
game.ReplicatedStorage.TelekeneticEvent.OnServerEvent:Connect(function(player,instance,direction)
if instance and instance:IsA("BasePart") and instance:HasTag("tele") then
print("retrieved")
instance.Velocity += (direction * 8)
end
end)
this is not the BEST code but it did work until now.