Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make a client sided projectile?

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

✓ Accepted answer

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 ...

4 comments

0

How would I make it so everyone could see the projectile?

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.

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

0

I found out how to do it thanks anyways :D

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.