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

I Turned a script into a local script but it does not work, could anyone help me solving this?

Asked by 2 years ago
Edited 2 years ago

Hello! So, i turned this script

01local Part = script.Parent
02 
03while true do
04    wait (0.001)
05    Part.Transparency = 1
06    Part.CanCollide = false
07    wait(30)
08    Part.Transparency = 0
09    Part.CanCollide = true
10    wait (1)
11end

into a local script but it doesn't work. I'm not great at scripting and maybe I am doing it in the wrong way, it could also be because i think that it should work like this but it actually does not. Basically i wanna make it so that when a player touches a part it disappears only for him, could anyone help me?

Script that i meant to put:

01local part = script.Parent
02local debounce = true
03 
04part.Touched:Connect(function(hit)
05    local humanoid = hit.Parent:FindFirstChildWichIsA("Humanoid")
06    if humanoid and debounce == true then
07        debounce = false
08        wait(1)
09        part.Transparency = 1
10        part.CanCollide = false
11        wait(1)
12        part.Transparency = 0
13        part.CanCollide = true
14        debounce = true
15    end
16end)

I'm so sorry

2 answers

Log in to vote
0
Answered by 2 years ago

Solution


Using the local script to make a part disappear on client? make sure the local script is parented or any so related to the player; maybe under character or player, this is probably what you want to do:

1local Part = game.Workspace.Part
2 
3while wait(30) do
4    Part.Transparency = 0
5    Part.CanCollide = true
6    wait(1)
7    Part.Transparency = 1
8    Part.CanCollide = false
9end

Parent your script under the Player or Character

Remember: Local means, a Client; by that it means, the changes that will happen by Local Script will only happen on Client and the nothing will change for other users.

if this is not what you meant, and you want to change it for all players, leave it as it is.

Short Explanation of Local Scripts


Local Script are replicated, (Distributed among players), if a Local Script isnt parented to a player or the Character, (Written by "xXMadonXx " above) it loses its functionality, a Local Script has to be assigned to a Player, so it knows which client these changes will appear on, another fact is If the Client changes (local script is now parented to another player), the Local Script will error, this is because the script migrated to a user it was never assigned to (replicated to).

feel free to ask questions! any doubts, search it up.

This is 1OOYearsWIthZ0MBlE

Cya!

0
Thank you so much dude! hellmet1 42 — 2y
0
I'm so sorry! I actually meant to put another script in the description! I'm so dumb! local part = script.Parent local debounce = true part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChildWichIsA("Humanoid") if humanoid and debounce == true then debounce = false wait(1) part.Transparency = 1 part.CanCollide = false wait(1) part.Transparency = 0 part.CanCo hellmet1 42 — 2y
0
Okay, i changed this script and instead of script.Parent i put game.Workspace.Part, i parented it to starterplayerscripts and startercharacterscripts but it doesn't work. I'm 100% sure I am doing something wrong though. hellmet1 42 — 2y
Ad
Log in to vote
0
Answered by
xXMadonXx 190
2 years ago

LocalScripts do no run in Workspace.

They only run in Player and Character. Basically in the Workspace the LocalScript does not know to which client it is assigned.

0
Oh,okay, then, is there any way to do this? hellmet1 42 — 2y

Answer this question