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 1 year ago
Edited 1 year ago

Hello! So, i turned this script

local Part = script.Parent

while true do
    wait (0.001)
    Part.Transparency = 1 
    Part.CanCollide = false
    wait(30)
    Part.Transparency = 0
    Part.CanCollide = true
    wait (1)
end

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:

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.CanCollide = true
        debounce = true
    end
end)

I'm so sorry

2 answers

Log in to vote
0
Answered by 1 year 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:

local Part = game.Workspace.Part

while wait(30) do
    Part.Transparency = 0
    Part.CanCollide = true
    wait(1)
    Part.Transparency = 1
    Part.CanCollide = false
end

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 — 1y
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 — 1y
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 — 1y
Ad
Log in to vote
0
Answered by
xXMadonXx 190
1 year 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 — 1y

Answer this question