Does anyone know how I would turn this into a serverscript?

Right now players only shoot their projectiles locally, but I want these to be seen and interacted with by others. I’ve tried but i’m having little luck making this into a serverscript. Does anyone know what i’d change and how i’d do this?

localscript inside starterpack:

repeat wait() until game.Players.LocalPlayer
 player = script.Parent.Parent
 mouse = player:GetMouse()
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://6929860536'
playercolor = player.Character.Torso.BrickColor
local sound = Instance.new("Sound")
local cooldown = false

whilecooldown = false do
mouse.KeyDown:connect(function(key)
		if key == "e" then
			
			cooldown = true
			local projectile = Instance.new("Part")
			sound.Parent = player.Character.Torso
			sound.SoundId = 'rbxassetid://4797903038'
			 bt = Instance.new("BodyThrust")
			 bf = Instance.new("BodyForce")
			bt.Parent = projectile
			bf.Parent = projectile
			bt.Force = Vector3.new(0, 0, -1000)
			bf.Force = Vector3.new(0, 290, 0)
			projectile.Size = Vector3.new(1,1,2)
			projectile.Position = player.Character.HumanoidRootPart.Position
			projectile.Orientation = player.Character.HumanoidRootPart.Orientation
			projectile.CanCollide = false
			local LoadAnimation = player.Character.Humanoid:LoadAnimation(Animation)
			LoadAnimation:Play()
			projectile.Parent = game.Workspace
			sound:Play()
			projectile.Material = ("Neon")
			projectile.BrickColor = (playercolor)
			wait(1)
			projectile:Destroy()
			wait(2)
			cooldown = false
	end
	end)
end

1 Like

Oh yeah i’m using them for player health, I was just dumb and didn’t think about it here whoops

2 Likes

Do you know where I would start the event and what I would have after it is started?

A lot of the stuff i’d want to do in the event requires things I made before I would fire it, I just don’t know what I would have to change and I don’t know if all of that is stuff compatible with a server script too

I still don’t get what you mean, would I need to set up all those things above “== e” again in my server script? All the code inside of that is completely dependent on things I created before the keypress