So as some have seen in my last post I am making a story game to see how it would turn out. I feel like its a nice way to get ahold of some more advanced scripting that I do not know of yet.
I made it where when you enter the first of three elevators and get a StringValue named “Elevator1”.
Does anyone know how I would destroy the StringValue out of the player when they hit the ExitButton?
Remove the parameter “plr”, of the function, and name “plr”, the game.Players.LocalPlayer part. Also, please don’t post screenshots of code, just formate it, then i will explain better.
It seems like you don’t know how to reference the local player correctly. Here’s what you should be doing.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
script.Parent:MouseButton1Click:Connect(function()
for _, child in pairs(player:GetChildren()) do
if child.Name == "Elevator1" then
child:Destroy()
-- Do any other logic here
break
end
end
end)