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

How do I add a model with a clickdetector and a script in it?

Ok, Im doing a house that has a forsalesign and when you click on it you own the house. I need help with the forsalesign removal and for it to come back when the player who claimed the house leaves the game. I have tried this so far but it didn't work

local clickDetector2 = script.Parent:WaitForChild("ForSaleSign1ClickDetector")
local Forsalesign = script.Parent
local Player = game.Players.LocalPlayer
	clickDetector2.MouseClick:Connect(function(player)
		if player.name ~= game.Workspace.houses.House2.CurrentOwner.Value then
			game.Workspace.houses.House1.CurrentOwner.Value = player.Name
			script.Parent.Parent["Nobody's House"].Name = game.Workspace.houses.House1.CurrentOwner.Value
			wait(0.1)
			script.Disabled = true
			Forsalesign.Wood.Transparency = 1
			Forsalesign.Wood.CanCollide = false
			Forsalesign.RedPart.Transparency = 1
			Forsalesign.RedPart.Decal.Transparency = 1
			
			Player.PlayerRemoving:Connect(function(player)
				Forsalesign.Wood.Transparency = 0
				Forsalesign.Wood.CanCollide = true
				Forsalesign.RedPart.Transparency = 0
				Forsalesign.RedPart.Decal.Transparency = 0
			
			end)
			
			end
		end)
  

1 answer

From what I understand you can probably move the Forsalesign somewhere outside of the workspace after someone has claimed it . Preferably move it to ServerScriptService because your script is inside of the model and it needs to continue running.

Once the player leaves you can put it back into the workspace for others to see it and claim it again.

1 comment

0

I tried but It doesn't work atleast in a localserver test

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