I'm making a character customization GUI and I'm stuck on the Hair part, I'm using a objectvalue to find a union in a folder under ReplicatedStorage after a textbutton has been clicked. I'm using a local script to check if the button is pressed and to fire an event and a clones the hair and welds it to the player. Can anyone tell me why the value of the objectvalue changes in play solo mode but not in the actual game? Everything works fine but the part that changes the value
local script
local plr = game.Players.LocalPlayer
local boyFrame = script.Parent.BoyFrame
local replicatedstorage = game:GetService("ReplicatedStorage")
local urFolder = replicatedstorage:WaitForChild(plr.Name)
local hairChoosen = urFolder:WaitForChild("HairChoosen")
local hairEvent = replicatedstorage:WaitForChild("HairEvent")
local Hairs = replicatedstorage:WaitForChild("Hairs")
local boyHair = Hairs.BoyHairs
for i,v in pairs(boyFrame:GetChildren()) do
if v and v:IsA("TextButton") then
v.MouseButton1Down:connect(function()
wait(0.4)
print(v.Name)
if v.Name == "Hair1" then
hairChoosen.Value = boyHair:WaitForChild("Hair1")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair2" then
hairChoosen.Value = boyHair:WaitForChild("Hair2")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair3" then
hairChoosen.Value = boyHair:WaitForChild("Hair3")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair4" then
hairChoosen.Value = boyHair:WaitForChild("Hair4")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair5" then
hairChoosen.Value = boyHair:WaitForChild("Hair5")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair6" then
hairChoosen.Value = boyHair:WaitForChild("Hair6")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair7" then
hairChoosen.Value = boyHair:WaitForChild("Hair7")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair8" then
hairChoosen.Value = boyHair:WaitForChild("Hair8")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair9" then
hairChoosen.Value = boyHair:WaitForChild("Hair9")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair10" then
hairChoosen.Value = boyHair:WaitForChild("Hair10")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
elseif v.Name == "Hair11" then
hairChoosen.Value = boyHair:WaitForChild("Hair11")
print(hairChoosen.Value)
wait(1)
print("bog hed")
hairEvent:FireServer()
print("fvk")
boyFrame.Visible = false
script.Parent.VisScript.Disabled = true
script.Parent.InvisScript.Disabled = false
wait(.1)
end
end)
end
end
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local hairEvent = Instance.new("RemoteEvent", ReplicatedStorage)
hairEvent.Name = "HairEvent"
local function onHairPicked(plr)
local urFolder = ReplicatedStorage:WaitForChild(plr.Name)
local hairChoosen = urFolder:WaitForChild("HairChoosen")
local Hairs = ReplicatedStorage:WaitForChild("Hairs")
local boyHair = Hairs.BoyHairs
local char = plr.Character
wait(0.7)
print("recieved")
print(hairChoosen.Value)
if hairChoosen.Value == boyHair:FindFirstChild("Hair1") then
print("hi")
local Hair1 = boyHair:WaitForChild("Hair1"):Clone()
Hair1.Parent = char
Hair1.Orientation = Vector3.new(0,0,0)
Hair1.CanCollide = false
Hair1.Anchored = false
local Weld = Instance.new("Weld")
Weld.Parent = char.Head
Weld.Part0 = char.Head
Weld.Part1 = Hair1
Weld.C0 = CFrame.Angles(0.05,-50.5,0)
Weld.C1 = CFrame.new(-0.1,-.6,-0.25)
elseif hairChoosen.Value ~= "Hair1" then
return
end
end
hairEvent.OnServerEvent:connect(onHairPicked)
