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

The script works only in studio, not in the actual game, any solutions?

Asked by
Echtic 128
5 years ago
Edited 5 years ago

Just a local script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()


    player.Character.Head.h:Destroy()

        wait()

    local h1 = game.ReplicatedStorage.Hairs.h1:Clone()
    h1.Name = "h"
    h1.Parent = player.Character.Head

    local weld = Instance.new("Weld")
    weld.Parent = h1
    weld.Part0 = player.Character.Head
    weld.Part1 = h1
    weld.C0 = CFrame.new(0,0,0)
    weld.C1 = CFrame.new(0,-0.5,0)



end)

When using events:

Local Script:

script.Parent.MouseButton1Click:Connect(function()


    workspace.Events.h1:FireServer()


end)

Server Script:

wait()
script.Parent.OnServerEvent:Connect(function(player)

    player.Character.Head.h:Destroy()

        wait()

    local h1 = game.ReplicatedStorage.Hairs.h1:Clone()
    h1.Name = "h"
    h1.Parent = player.Character.Head

    local weld = Instance.new("Weld")
    weld.Parent = h1
    weld.Part0 = player.Character.Head
    weld.Part1 = h1
    weld.C0 = CFrame.new(0,0,0)
    weld.C1 = CFrame.new(0,-0.5,0)



end)

Both of these ways work only in studio.

0
Can you revert back to the events? This only works in studio because you're either using LocalPlayer in a server script or trying to clone something and replicate it to all clients in a local script. MythicalShade 420 — 5y
0
on it Echtic 128 — 5y
0
Done, the question itself has changed go ahead and take a look, hope u find a solution. Echtic 128 — 5y
0
What parts of the script work? Does the player's head get destroyed when using just the local script? Pojoto 329 — 5y
0
h means hair, and everything works perfectly in the studio, but nothing works in the game Echtic 128 — 5y

Answer this question