Hey Everyone! I've been really into learning about programming in Roblox and I've made some progress but I'm still somewhat of a noob and I'm in need of help.
I am trying to program a Platform that a Player can spawn in front of them and click on it to make it disappear.
The Platform is named "CloneBlock2" and is stored in StarterPlayer, it has a ClickDetector and a script that programs it to be Destroyed when Clicked on. The Script on the Platform.
local Player = game.Players.LocalPlayer
local function onMouseClick(player)
script.Parent:Destroy()
end
script.Parent.ClickDetector.MouseClick:connect(onMouseClick)
The Platform works If I play the game with the Platform already in the Workspace when I start the game. But If I store the Platform in StarterPlayer and spawn a clone of the Platform using a local script in StarterGui it doesnt run the script that's attached to the Platform. Not sure what I am doing wrong. Hopefully someone can help me with this.
Here is the StarterGui script.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local CloneBlock2 = game.StarterPlayer.CloneBlock2
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
Key = Key:lower()
if Key == '2' then
CloneBlock2.CFrame = Player.Character.Head.CFrame * CFrame.new(0,0,-5)
local Clone2 = CloneBlock2:Clone()
Clone2.Parent = game.Workspace
end
end)
Formatting is off when I copy pasted code. Sorry about that, I don't know how to properly copy/paste code here from Roblox and keep formatting.
Anyhow, I would greatly appreciate some advice on how to get this working or if there's altogether a better more efficient way to do this then I'd love to learn about it.
