Server side scripts

So I’ve recently started to try and make one of my first proper games but while testing with a friend i noticed that they cannot see another persons ability. I looked into that and found out localscripts aren’t FE so other ppl can’t see them I’d like to know how i would make this script so other people can see it. I am aware of remotefunctions and stuff but since server side scripts are a bit different and you can’t just copy your localscript code into them i’ve got no clue how to start so i’d like a bit of help.

i know it’s not that optimized but it works so i don’t really want to change the localscript itself
this is the localscript:

script.Parent.Activated:Connect(function()
	local player = game.Players.LocalPlayer
	local char = game.Players.LocalPlayer.Character
	local pos = char.UpperTorso.Position
	local blue2 = game.ReplicatedStorage["Hollow Purple Windup"]["Hollow Purple : Blue"]:Clone()
	local red2 = game.ReplicatedStorage["Hollow Purple Windup"]["Hollow Purple : Red"]:Clone()
	local purple2 = game.ReplicatedStorage["Hollow Purple"].PrimaryPart:Clone()
	blue2.Parent = workspace
	red2.Parent = workspace
	purple2.Parent = workspace
	local blue = blue2
	local red = red2
	local purple = purple2
	blue.Position = player.Character.HumanoidRootPart.CFrame*Vector3.new(10,0,5)
	wait(2)
	red.Position = player.Character.HumanoidRootPart.CFrame*Vector3.new(-10,0,5)
	wait(0.01)
	blue.custom.Enabled = true
	wait(0.5)
	local target = Instance.new("Part")
	target.Position = player.Character.HumanoidRootPart.CFrame*Vector3.new(0,0,-5)
	local part = blue

	local TweenService = game:GetService("TweenService")

	local tweenInfo = TweenInfo.new(

		1, --Time

		Enum.EasingStyle.Linear, --Easing Style

		Enum.EasingDirection.Out, --EasingDirection

		0, --Repeat Count

		false, --Reverse

		0 --DelayTime

	)
	local tween = TweenService:Create(part, tweenInfo, {Position = target.Position})
	tween:Play()

	local part = red

	local TweenService = game:GetService("TweenService")

	local tweenInfo = TweenInfo.new(

		1, --Time

		Enum.EasingStyle.Linear, --Easing Style

		Enum.EasingDirection.Out, --EasingDirection

		0, --Repeat Count

		false, --Reverse

		0 --DelayTime

	)
	local tween = TweenService:Create(part, tweenInfo, {Position = target.Position})
	tween:Play()
	wait(1)
	local target2 = Instance.new("Part")
	target2.Position = player.Character.HumanoidRootPart.CFrame*Vector3.new(0,10,-10)
	purple.Position = target2.Position
	purple.Orientation = char.Head.Orientation
	blue:Destroy()
	red:Destroy()
	local target3 = Instance.new("Part")
	target3.Position = player.Character.HumanoidRootPart.CFrame*Vector3.new(0,10,-1000)
	wait(0.5)
	local part = purple

	local TweenService = game:GetService("TweenService")

	local tweenInfo = TweenInfo.new(

		5, --Time

		Enum.EasingStyle.Linear, --Easing Style

		Enum.EasingDirection.Out, --EasingDirection

		0, --Repeat Count

		false, --Reverse

		0 --DelayTime

	)
	local tween = TweenService:Create(part, tweenInfo, {Position = target3.Position})
	tween:Play()
	wait(5)
	purple:Destroy()
end)
1 Like

You can probably copy the entire script into a server script but change local variables like LocalPlayer into a different method of getting their character on the server

1 Like

well yeah that’s where my main problem is i’ve got no clue how to get players and such in a server sided script

What is the script’s parent? Given that you’re using Activated, it might be passing a player parameter.

If it’s a tool, you can just use GetPlayerFromCharacter and script.Parent.

You can get players using game:GetService("Players"). You can then specify the name. If you need the player that’s holding the tool, use Players:GetPlayerFromCharacter(characterModel : Model).

local players = game:GetService("Player")
local localPlayer

script.Equipped:Connect(function()
	local model = script:FindFirstAncestorWhichIsA("Model")
	localPlayer = players:GetPlayerFromCharacter(model)
end)

script.Unequipped:Connect(function()
	localPlayer = nil
end)

-- Use localPlayer == nil to check if your effects should run when the tool is activated.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.