I am trying to make a ball go to a part when the event is fired but I don’t know how to fire an event.
local ballEvent = game.ReplicatedStorage:WaitForChild("BallEvent")
local ball = game.Workspace:WaitForChild("Ball")
local particle = script.Parent.Attachment.ParticleEmitter
function onTouch()
if (ball ~=nil) then
particle:Clear()
particle:Emit(10)
wait(1)
ball.Transparency = 1
ball.Highlight.OutlineTransparency = 1
end
end
ball.Touched:Connect(onTouch)
personally I would use the deprecated fireServer because it’s funny (when exploiters try and hook it majority of them just hook the __namecall metamethod which requires them to use getnamecallmethod which majority of them only know about the “FireServer” namecall method and not the deprecated one which is “fireServer”) plus there is no downside to it because if you compare the deprecated method to the current one it returns the same
local Remote = Instance.new("RemoteEvent")
print(Remote.FireServer == Remote.fireServer) --> true
local ballEvent = game.ReplicatedStorage:WaitForChild("BallEvent")
local ball = game.Workspace:WaitForChild("Ball")
local particle = script.Parent.Attachment.ParticleEmitter
function onTouch()
if (ball ~=nil) then
particle:Clear()
particle:Emit(10)
wait(1)
ball.Transparency = 1
ball.Highlight.OutlineTransparency = 1
ballEvent:FireServer()
end
end
ball.Touched:Connect(onTouch)
Deprecated means discontinued and can be removed at any time. Sure, it might be funny but the risk of it might stop existing or working one day would be pretty problematic. Plus all they have to do is to change one letter lol.
Change the remote event instance to a bindable event instead. Just remember to give it the same name so that you don’t need to update your variables again.
Remote events are something that you want to fire either to clients or to servers.
if you fire it from a client script, you can fire it to a server
if you fire it from a server script, you can fire it to clients
if you wanna fire it between server to server, you need to make a client script that recieves and sends that
when you fire a event:
- to server
event:FireServer(put anything or none)
- to client
event:FireClient(put anything or none)
when you recieve a event
- server
event.OnServerEvent:Connect(function()
end)
- Client
event.OnClientEvent:Connect(function()
end)
Seeing you want to fire the event when the ball goes to a part, you do this
after ball touch function
ballEvent:FireServer(anything_or_none)
Or if im mistaken and you want the ball to go to a part when a event is fired
- from client
ballEvent:FireServer()
- to your server script
ballEvent.OnServerEvent(function()
Your code to move the ball
end)