Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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.

01local Workspace = game.Workspace
02 
03local mainpart = Workspace.Touchablewall1
04local secondarypart = Workspace.Part28
05local thirdpart = Workspace.Part29
06local secondmainpart = Workspace.Touchablewall2
07local Players = game:GetService("Players")
08 
09local db = true
10mainpart.Touched:connect(function(hit)
11    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
12        if db == true then
13            db = false
14            secondarypart.Transparency = 1
15            secondarypart.CanCollide = false
View all 38 lines...

-----other script

01local Workspace = game.Workspace
02 
03local mainpart = Workspace.Touchablewall2
04local secondarypart = Workspace.Part29
05local thirdpart = Workspace.Part28
06local secondmainpart = Workspace.Touchablewall1
07 
08local db = true
09mainpart.Touched:connect(function(hit)
10    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
11        if db == true then
12            db = false
13            secondarypart.Transparency = 1
14            secondarypart.CanCollide = false
15            mainpart.Transparency = 0
View all 37 lines...
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. boredlake 256 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

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. MuhammadHH11 2 — 2y
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. SashaPro336 47 — 2y
0
Also i dont recommend you to change leaderstats using local script, because you cant save it in the future and other. SashaPro336 47 — 2y
0
Thank you! MuhammadHH11 2 — 2y
0
:D SashaPro336 47 — 2y
Ad

Answer this question