You can write your topic however you want, but you need to answer these questions:
In my game I am making a building simulator type game.
I have a button to delete all of your work only, but leave the others.
I am trying to use this script to do that but it didn’t work:
The issue is it not deleting my parts that I have placed.
script.Parent.MouseButton1Click:Connect(function()
local name = script.Parent.Parent.Parent.Parent.Name
local RS = game:GetService("ReplicatedStorage")
if workspace:IsA("StringValue") then
if workspace:IsA("StringValue").Value == name then
workspace:IsA("StringValue").Parent:Destroy()
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
local name = script.Parent.Parent.Parent.Parent.Name
local RS = game:GetService("ReplicatedStorage")
if workspace:IsA("StringValue") then
if workspace:IsA("StringValue").Value <= name then
workspace:IsA("StringValue").Parent:Destroy()
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
local name = script.Parent.Parent.Parent.Parent.Name
local RS = game:GetService("ReplicatedStorage")
if workspace:IsA("StringValue") then
if game.workspace:IsA("StringValue").Value == name then
game.workspace:IsA("StringValue").Parent:Destroy()
end
end
end)
I don’t think having greater than or equal to a string is possible, only for numbers
From what I can tell, it seems like you’re trying to get the name of the ScreenGui. Are you? Also, please don’t use server scripts for UI. Use a client script instead
Nevermind, I read that wrong. If you are getting the name of the player, using .LocalPlayer would be easier and more efficient. Change this to a client script
script.Parent.MouseButton1Click:Connect(function()
local name = script.Parent.Parent.Parent.Parent.Parent.Name
local RS = game:GetService("ReplicatedStorage")
if workspace:IsA("StringValue") then
if workspace:IsA("StringValue").Value == name then
workspace:IsA("StringValue").Parent:Destroy()
end
end
end)
You are checking if workspace is a StringValue, and not if any descendants are StringValue’s. Use for i, v in pairs.
Try this in a local script:
local player = game:GetService("Players").LocalPlayer
local name = player.Name
script.Parent.MouseButton1Click:Connect(function()
for i, v in pairs(workspace:GetDescendants()) do
if v:IsA("StringValue") then
if v.Value == name then
v.Parent:Destroy()
end
end
end
end)