Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

.

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)

5 comments

0

Also, Ingame, Press F9 to view debug console to see if it prints any errors.

0

It is a Gui -_-

0

You mentioned that it is a part..

0

No, I mentioned that the WaypointMarker is a part, I'm not calling MouseButton1Click on WaypointMarker

0

There we go, that should work(edited answer)

This discussion is preserved as it was. New answers, comments, and votes are closed.