You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’m trying to get it to where when I press this button it will Equip the trail and then click the button again to unequip it. -
What is the issue? Include screenshots / videos if possible!
when I go to Unequip it, it gives me this error.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked at some other posts but none of them relate to my code/issue
This is my Server Script
local repStorage = game:GetService("ReplicatedStorage")
local equipTrail = repStorage.EquipTrail
equipTrail.OnServerEvent:Connect(function(plr, trailName, trail)
if trailName then
trailName:Destroy()
else
local newTrail = trail:Clone()
newTrail.Parent = plr.Character
local weldConst = Instance.new("WeldConstraint")
weldConst.Parent = newTrail
weldConst.Part0 = newTrail
weldConst.Part1 = plr.Character.UpperTorso
newTrail.Position = plr.Character.UpperTorso.Position
end
end)
this is my LocalScript
local button = script.Parent
local players = game:GetService("Players")
local plr = players.LocalPlayer
local repStorage = game:GetService('ReplicatedStorage')
local trail = repStorage.RainbowTrail
local equipTrail = repStorage.EquipTrail
local removeCoins = repStorage.RemoveCoins
local changeValue = repStorage.ChangeTrailValue
button.MouseButton1Click:Connect(function()
if plr.HasRainbowTrail.Value == false then
if plr.Turkey.Value >= 120 then
changeValue:FireServer(plr.HasRainbowTrail)
removeCoins:FireServer(120)
button.Text = "Equip"
end
elseif button.Text == "Unequip" then
button.Text = "Equip"
equipTrail:FireServer()
elseif plr.HasRainbowTrail.Value == true then
button.Text = "Unequip"
equipTrail:FireServer(plr.Character:FindFirstChild("RainbowTrail"), game.ReplicatedStorage.RainbowTrail)
end
end)