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

This Local Script works in Studio, why not in Game?

Asked by 10 years ago

I have this script:

local c = nil
local sB = script.Parent.SetButton
local rB = script.Parent.RemoveButton
local char = game.Players.LocalPlayer.Character

sB.MouseButton1Click:connect(function()
    c = char.Torso.CFrame
    if(char.LocalBin:FindFirstChild("WaypointMarker")) then char.LocalBin.WaypointMarker:Destroy() end
    m = game.Lighting.WaypointMarker:Clone()
    m.CFrame = c
    m.Parent = char.LocalBin
end)
rB.MouseButton1Click:connect(function()
    char.LocalBin.WaypointMarker:Destroy()
end)

Just to clarify the waypoint marker is a Part with a Script inside it that makes it spin, also sB and rB are text buttons. What it does is once you click the button it clones the Part to your Torso and then once you click the second button it removes it. If you click the second button twice it removes the first Part. This works fine in Studio but the Part doesn't show up in the actual game. At the moment you can test it here.

1 answer

Log in to vote
1
Answered by 10 years ago

.

local c = nil
local sB = script.Parent.SetButton
local rB = script.Parent.RemoveButton
local char = game.Players.LocalPlayer.Character

sB.MouseButton1Click:connect(function()
    c = char.Torso -- you cannot call a CFrame without CFraming anything, so we just call the part
    if(char.LocalBin:FindFirstChild("WaypointMarker")) then char.LocalBin.WaypointMarker:Destroy() end
    m = game.Lighting.WaypointMarker:Clone()
    m.CFrame = c.CFrame -- we add CFrame here
    m.Parent = char.LocalBin
end)
rB.MouseButton1Click:connect(function()
    char.LocalBin.WaypointMarker:Destroy()
end)
0
Also, Ingame, Press F9 to view debug console to see if it prints any errors. killerkill29 35 — 10y
0
It is a Gui -_- Norshine 88 — 10y
0
You mentioned that it is a part.. killerkill29 35 — 10y
0
No, I mentioned that the WaypointMarker is a part, I'm not calling MouseButton1Click on WaypointMarker Norshine 88 — 10y
0
There we go, that should work(edited answer) killerkill29 35 — 10y
Ad

Answer this question