Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make a client sided projectile?

Asked by 3 years ago

I've been looking everywhere but I can't find any examples or explanations I understand so could anyone please try and explain with some examples?

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

To make a client-sided projectile you need server script, local script, and remote event.

in the server script, you put remote:FireClient() to fire the event when your conditions are true (example)

local rs = game:GetService("ReplicatedStorage")
local remote = rs:WaitForChild("RemoteEvent")
local part = workspace.Part

part.Touched:Connect(function(otherpart)
    local char = otherpart.Parent
    local player = game.Player:GetPlayerFromCharacter(char)
    if player then
    remote:FireClient(player)
    end
end)

then on the local script, you put remote.OnClientEvent and connect it to function, this will make the local script wait for the remote to fire from the server script.

local rs = game:GetService("ReplicatedStorage")
local remote = rs:WaitForChild("RemoteEvent")

remote.OnClientEvent:Connect(function()
    local part = Instance.new("Part",workspace)
    part.Name = "PART"
    part.Material = Enum.Material.Neon


end)

The script will create a part that only the player can see.So this is the basics of client-side events you do the same but you replace the code inside the function with cloning the projectile and CFrame and stuff to make projectiles whatever u are aiming for ...

0
How would I make it so everyone could see the projectile? FuZioNToxic 7 — 3y
0
since we used server script , local script and remote event ... u have to put remote:FireServer() in local script and remote:OnServerEvent(player) in the server script ... you put the code of projectile in the server script and in local script u put the event that will fire the :FireServer function. Mikael20143 138 — 3y
0
That would make the projectile on the server, wouldn't it? If that's the case I already know how to do that and it's not what I'm trying to do rn what I'm trying to do is make the projectile visible on all clients without using the server to create it FuZioNToxic 7 — 3y
0
I found out how to do it thanks anyways :D FuZioNToxic 7 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

To create a client-sided projectile, simply fire a RemoteEvent to all clients. Each client can then create the necessary object(s) needed for the projectile, and change the position locally. This is better as opposed to the server doing this because it's redundant.

Answer this question