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

Moving scripts from inside a block into server script storage?

Asked by 4 years ago

I've been trying to learn how to script and I've done some basic stuff and edited some scripts. A friend of mine told me instead of having several scripts inside parts, it'll be better to have them in server script storage. I edited this script I had and put it in server script storage, first error I received was "touched is not a valid member of ServerScriptStorage". I don't know how to fix this but what I'm wanting to do is that when a player comes in touch with the block "Pendulum", the block is no longer anchored and it starts moving.

-- Unanchor OBSTACLES
h = workspace.Res1.OBS41.DoublePendulum.Pendulum

function touch(hit)
        wait (0.01)
        h.Anchored = false
    end 

script.Parent.Touched:Connect(touch)

2 answers

Log in to vote
0
Answered by 4 years ago

The problem here is the last line :

script.Parent.Touched:Connect(touch)

Touched of course is a not valid member of ServerScriptStorage because player can't touch it xd So what will you do to fix this ? Here is a solution You change the last line to

h.Touched:Connect(touch)
0
i would recommend you to put the script inside the part though Nguyenlegiahung 1091 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I would advise not to put scripts that interact with the Workspace inside ServerScriptService. I would only put scripts that control game logic amongst others inside ServerScriptService.

Things like handling gamepass purchases, datastore logic, etc.

Answer this question