Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Code working in studio but not in game?

Asked by
RoyMer 301 Moderation Voter
9 years ago

I have made 3 BrickColorValues in the player, in a Model called HorseColour, but for some reason this script is working in studio but not in game? It is a server script... (It was working before until I added those 3 lines marked)

owner = script.Parent.Parent.Parent.OwnerName

function onTouched(hit) 
    local check = hit.Parent:FindFirstChild("Humanoid") 

    if check ~= nil then
    if hit.Parent.Name == owner.Value then 

    if script.Parent.Parent.Ready.Value == true then

    if script.Parent.Parent:FindFirstChild("Horse") then
    script.Parent.Parent.Horse:Destroy()

    elseif not script.Parent.Parent:FindFirstChild("Horse") then    
    script.Parent.Parent.Ready.Value = false    

    local player = game.Players.LocalPlayer 
    local clone = game.ReplicatedStorage.TycoonModels.Horse:Clone()

    --Since I added the following 3 lines:
    clone.BaseColor.Value = player.HorseColour.BaseColor.Value
    clone.SaddleColor.Value = player.HorseColour.SaddleColor.Value
    clone.ManeColor.Value = player.HorseColour.ManeColor.Value

    clone.Parent = script.Parent.Parent
    clone:MoveTo(script.Parent.Parent.HorseSpawn.Position)
            end 
        end 
    end 
end 
    wait(10)
    script.Parent.Parent.Ready.Value = true 
end
script.Parent.Touched:connect(onTouched) 

Answer this question