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

Localscript cloned from localscript doesn't run?

Working on a projectile system. The problem is that sometimes projectiles will have special effect that run on a localscript(the script named "p"). However for some reason the "p" script never runs

Heres the script that clones the "p" script

local bucket=game:GetService("Debris")
game.ReplicatedStorage.Remotes.ProcessProjectile.OnClientEvent:connect(function(player,object,duration,velocity,cframe)
	local newprojectile=object:clone()
	newprojectile.BodyVelocity.MaxForce=Vector3.new(math.huge,math.huge,math.huge)
	newprojectile.BodyVelocity.Velocity=velocity
	newprojectile.CFrame=cframe
	local pfx=newprojectile:FindFirstChild("p")
	if pfx~=nil then
		pfx.follow.Value=newprojectile
		pfx.Parent=player.Character
		bucket:AddItem(pfx,duration)
	end
	newprojectile.Parent=game.Workspace
	bucket:AddItem(newprojectile,duration)
end)

and although I don't think this'll be useful heres the p script

print("am I working?")

Also "yes" this is a repost

1 answer

Ok just figured it out. So apparently when you clone a localscript you need to specify its owner (a player) by placing the script in player.PlayerScripts. Or atleast thats what worked for me

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