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

How can I change a property of a part for the localplayer?

I have made a code when you touch a block the properties of an other part changes. It works, but everyone sees it. I want that the property only changes for the local player. Can someone help me? these are the codes I have made 2 local scripts in the startergui.

local Workspace = game.Workspace

local mainpart = Workspace.Touchablewall1
local secondarypart = Workspace.Part28
local thirdpart = Workspace.Part29
local secondmainpart = Workspace.Touchablewall2
local Players = game:GetService("Players")

local db = true
mainpart.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			secondarypart.Transparency = 1
			secondarypart.CanCollide = false
			mainpart.Transparency = 0
			thirdpart.CanCollide = true
			thirdpart.Transparency = 0
			secondmainpart.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
			mainpart.Transparency = 0
			secondarypart.Transparency = 1
			secondarypart.CanCollide = false
			thirdpart.CanCollide = true	
			thirdpart.Transparency = 0
			secondmainpart.Transparency = 1
			wait(0.1)
			db = true
			mainpart.Transparency = 1
			secondarypart.Transparency = 0
			secondarypart.CanCollide = true
			thirdpart.CanCollide = false
			thirdpart.Transparency = 1
			secondmainpart.Transparency = 0
		end
	end	
end)

-----other script


local Workspace = game.Workspace

local mainpart = Workspace.Touchablewall2
local secondarypart = Workspace.Part29
local thirdpart = Workspace.Part28
local secondmainpart = Workspace.Touchablewall1

local db = true
mainpart.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			secondarypart.Transparency = 1
			secondarypart.CanCollide = false
			mainpart.Transparency = 0
			thirdpart.CanCollide = true
			thirdpart.Transparency = 0
			secondmainpart.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
			mainpart.Transparency = 0
			secondarypart.Transparency = 1
			secondarypart.CanCollide = false
			thirdpart.CanCollide = true
			thirdpart.Transparency = 0	
			secondmainpart.Transparency = 1
			wait(0.1)
			db = true
			mainpart.Transparency = 1
			secondarypart.Transparency = 0
			secondarypart.CanCollide = true
			thirdpart.CanCollide = false
			thirdpart.Transparency = 1
			secondmainpart.Transparency = 0
		end
	end	
end)

1 comment

0

Just a suggestion, you don't have to define local Workspace = game.Workspace as workspace is already a built-in variable that acts as the workspace.

1 answer

✓ Accepted answer

Just make that scripts local and put them into starter player scripts. Message me if it would work or not! If it wont work you should use an remote event with fire client.

5 comments

0

I made both script local scripts and I put them in starter player scripts but it didn't work. Can you help me with the script? I don't know how to use remote events and fire client.

0

Make an script (in part or server script storage), add variable with your remote event in rep storage, then when its get touched, use remote:FireClient. Then make your local script function activate on remote event with onClientEvent. This may help you.

0

Also i dont recommend you to change leaderstats using local script, because you cant save it in the future and other.

0

Thank you!

0

:D

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