When the local script is given to the player, its parent into the players character, They can see it only but no one else can, Or do i need to write an entire new script?

wait(0.5)
local player = game.Players.LocalPlayer
local pgui = player.PlayerGui
local character = player.Character
local head = character:findFirstChild("Head")
local torso = character:findFirstChild("Torso")
local hum = character:findFirstChild("Humanoid")

script.Parent = character

local r_serv = game:GetService("RunService")

local kls = script.KillShield
local tkd = script.TakeDamage
tkd.Value = false
kls.Value = false

local g1 = script.ShieldBilboard:clone()
g1.Enabled = true
g1.Adornee = head
local g2 = script.ShieldGUI:clone()

local defense_time = 2
local health = 3

local spart = Instance.new("Part")
spart.BrickColor = BrickColor.new("Toothpaste")
spart.formFactor = "Custom"
spart.Size = Vector3.new(0.2, 0.2, 0.2)
spart.CFrame = torso.CFrame
spart.TopSurface = 0
spart.BottomSurface = 0
spart.Transparency = 1
spart.Name = "ShieldPart"
local dlti = Instance.new("IntValue", spart)
dlti.Name = "DeleteMe"
local m = Instance.new("SpecialMesh", spart)
m.MeshType = "Sphere"
spart.Parent = character
local lg = Instance.new("PointLight", spart)
lg.Shadows = true
lg.Color = Color3.new(0, 1, 1)
lg.Brightness = 100
lg.Range = 0

hum.Died:connect(function()
	g1:remove()
	g2:remove()
	spart:remove()
end)

local w = Instance.new("Weld")
w.Part0 = torso
w.Part1 = spart
w.Parent = spart

local imgs = {"145252587", "145252589", "145252591", "145252593"}

local ric = {Instance.new("Sound", spart), Instance.new("Sound", spart)}
ric[1].SoundId = "http://www.roblox.com/asset/?id=145183456"
ric[1].Volume = 1
ric[2].SoundId = "http://www.roblox.com/asset/?id=145183460"
ric[2].Volume = 1

local loop = Instance.new("Sound", spart)
loop.Looped = true
loop.SoundId = "http://www.roblox.com/asset/?id=144764911"
loop.Volume = 1
coroutine.resume(coroutine.create(function()
	wait(0.4)
	loop:play()
end))


g1.Parent = character
g2.Parent = pgui

local sh1 = g1.Shield
local sh2 = g2.Frame.Shield
function SetState(st)
	sh1.Image = "http://www.roblox.com/asset/?id=" .. imgs[4 - st]
	sh2.Image = "http://www.roblox.com/asset/?id=" .. imgs[4 - st]
end
SetState(0)

function smoothstep(x)
	return x*x*(3 - 2*x)
end

local loadit = 0
while loadit < 0.8 do
	local st = tick()
	r_serv.RenderStepped:wait()
	loadit = math.min(0.8, loadit + (tick() - st))
	local am = loadit / 0.8
	spart.Transparency = 1 - (am * 0.1)
	spart.Reflectance = am * 0.3
	m.Scale = Vector3.new(smoothstep(am) * 31, smoothstep(am) * 31, smoothstep(am) * 31)
	loop.Volume = am * 0.6
	SetState(math.floor(am * 3))
	lg.Range = am * 5
end

local being_damaged = false
local run_anim = true

kls.Changed:connect(function()
	SetState(0)
	health = 0
	run_anim = false
end)
kls.Value = false

tkd.Changed:connect(function()
	if health == 0 then return end
	tkd.Value = false
	if not being_damaged then
		being_damaged = true
		spart.BrickColor = BrickColor.new("Lime green")
		lg.Color = Color3.new(0, 1, 0)
		loop.Volume = 1
		ric[math.random(1, #ric)]:play()
		
		
		local ld = 0
		while ld < defense_time do
			local st = tick()
			r_serv.RenderStepped:wait()
			ld = math.min(defense_time, ld + (tick() - st))
			
			local fls = math.floor(ld * 6)
			local gmode = (fls / 2 == math.floor(fls / 2))
			if gmode then
				SetState(health)
			else
				SetState(health - 1)
			end
		end
		
		health = health - 1
		SetState(health)
		if health == 0 then
			run_anim = false
		end
		
		loop.Volume = 0.6
		lg.Color = Color3.new(0, 1, 1)
		spart.BrickColor = BrickColor.new("Toothpaste")
		being_damaged = false
	end
end)
tkd.Value = false

while run_anim do
	r_serv.RenderStepped:wait()
	local mesh_sz = math.sin(math.rad(tick() * 90 * 0.5)) * 1
	m.Scale = Vector3.new(31 + mesh_sz, 31 + mesh_sz, 31 + mesh_sz)
	if not being_damaged then
		spart.Transparency = 0.9 + (math.cos(math.rad(tick() * 90 * 0.4)) * 0.03)
	else
		spart.Transparency = 0.8 + (math.cos(math.rad(tick() * 90 * 0.4)) * 0.03)
	end
end

local loadit = 0
while loadit < 0.8 do
	local st = tick()
	r_serv.RenderStepped:wait()
	loadit = math.min(0.8, loadit + (tick() - st))
	local am = 1 - (loadit / 0.8)
	spart.Transparency = 1 - (am * 0.1)
	spart.Reflectance = am * 0.3
	m.Scale = Vector3.new(smoothstep(am) * 31, smoothstep(am) * 31, smoothstep(am) * 31)
	loop.Volume = am * 0.6
	lg.Range = am * 5
end

g1:remove()
g2:remove()
spart:remove()
script:remove()





2 comments

0

You should send all the values and stuff to the server using remote functions or events and then do anything effecting other players in a script there

0

Alright