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
Just a suggestion, you don't have to define
local Workspace = game.Workspaceasworkspaceis already a built-in variable that acts as the workspace.