Longtime ROBLOX user who has just started scripting.
Working on a script that when a button is touched, it gives a player a trail. The code itself isn't in a local script, it's in a regular script and it works in test > play mode. I tried to move it to a local script, but then the script doesn't work.
I've been tinkering/researching with this for a few hours with no luck, would anyone be able to help me fix this? Thank you.
wait(1)
function onTouched(hit)
wait(1)
if not game.Players.LocalPlayer.Character.LowerTorso:FindFirstChild("FairyMagicTrail") then
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local trail = ReplicatedStorage.BloomMythixTrail:Clone()
trail.Parent = game.Players.LocalPlayer.Character.LowerTorso
local attachment0 = game.Players.LocalPlayer.Character.UpperBody.Left1.Attachment1
local attachment1 = game.Players.LocalPlayer.Character.UpperBody.Right2.Attachment1
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
end
if game.Players.LocalPlayer.Character.LowerTorso:FindFirstChild("FairyMagicTrail") then
end
end
script.Parent.Touched:connect(onTouched)

2 comments
Localplayer only exists in localscripts(and they must be inside the player) when running in online mode.
What's the workaround for that? Is there something else I can call to find the character that is stepping on the brick?