Hey guys, i’m trying to make a part that, when clicked by a player, the part disappears only for him. My script so far (it’s a normal script):
local ck = script.Parent
local badgeservice = game:GetService("BadgeService")
local id = 2153785678
ck.MouseClick:Connect(function(player)
if player.WitchesBrew.Value == 4 then
print("hooray")
badgeservice:AwardBadge(player.UserId,id)
script.Parent.Parent:Destroy()
else
player.WitchesBrew.Value += 1
print("added")
script.Parent.Parent:Destroy()
end
end)
assuming the part is the parent of ck (script.Parent.Parent)
you would need to make a new local script and place it in the same location as your normal script
in this local script you would put this code in
local ClickDetector = script.Parent
ClickDetector.MouseClick:Connect(function()
ClickDetector.Parent.Transparency = 1
end)
LocalScripts don’t run in the workspace - you will have to use a RemoteEvent.
Instructions if needed
Create a RemoteEvent in ReplicatedStorage named something along the lines of “HidePart”
Create a LocalScript in StarterPlayerScripts - name doesn’t matter
In the normal script, write:
local ck = script.Parent
local badgeservice = game:GetService("BadgeService")
local id = 2153785678
local hidePartEvent = game:GetService("ReplicatedStorage"):WaitForChild("HidePart")
ck.MouseClick:Connect(function(player)
if player.WitchesBrew.Value == 4 then
print("hooray")
badgeservice:AwardBadge(player.UserId,id)
else
player.WitchesBrew.Value += 1
print("added")
end
hidePartEvent:FireClient(player, script.Parent.Parent)
end)
In the LocalScript, write:
local replicatedStorage = game:GetService("ReplicatedStorage")
local hidePartEvent = replicatedStorage:WaitForChild("HidePart")
local function onHidePartEvent(part)
part:Destroy()
-- part.LocalTransparencyModifier = 1 Instead of destroying it, you could also just make it transparent, but whichever is better
end
hidePartEvent.OnClientEvent:Connect(onHidePartEvent)