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

Displaying trail behind players that own gamepass, disable on click?

Asked by 4 years ago

I'm still learning how this work and trying my best. I can't do this by myself so I followed some tutorials and did some basic editing myself.

The first script is a script that I have inside a textbutton/gui. Some players that own the gamepass simply don't want to have the trail behind them. "SpeedDemonTrail" is the trail in serverstorage and I tried to make it so when the player clicks the button, it disables the trail but it says "SpeedDemonTrail is not a member of server storage"

01local h = game.ServerStorage.SpeedDemonTrail
02local Debounce = false
03 
04script.Parent.MouseButton1Click:Connect(function()
05    if Debounce == false then
06        h.Enabled = false
07        script.Parent.Text = ("DemonTrail - OFF")
08        Debounce = true
09    else
10        h.Enabled = true
11        script.Parent.Text = ("DemonTrail - ON")
12        Debounce = false
13    end
14end)

The second script was the one I followed a tutorial to do and it creates a trail for the player

01local id = 8309369
02local Trail = game.ServerStorage["SpeedDemonTrail"]
03 
04game.Players.PlayerAdded:Connect(function(plr)
05    plr.CharacterAdded:connect(function(char)
06        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
07            local plrTrail = Trail:Clone()
08            plrTrail.Parent = char.Torso
09            plrTrail.Attachment0 = char.Head.FaceFrontAttachment
10            plrTrail.Attachment1 = char.Torso.WaistBackAttachment
11        end
12    end)
13end)
0
does an Object named 'SpeedDemonTrail' exist inside the serverstorage? If it does, then try using WaitForChild. Subsz 366 — 4y
0
It does exist inside ServerStorage. However when I hit play the first error I receive it's telling me "Blah SpeedDemonTrail is not a member of server storage". However everything else works properly ItsJZaid 45 — 4y
0
Try doing, game.ServerStorage:WaitForChild('SpeedDemonTrail') Subsz 366 — 4y
0
19:36:18.058 - Infinite yield possible on 'ServerStorage:WaitForChild("SpeedDemonTrail")'... Just got that while doing what you said ItsJZaid 45 — 4y
View all comments (4 more)
0
Could the issue possibly be that the trail is attached to the player and no longer exists in server storage by the time I try to enable/disable it? ItsJZaid 45 — 4y
0
That means that there is no object named SpeedDemonTrail inside the ServerStorage, are you sure SpeedDemonTrail is the exact name? Subsz 366 — 4y
0
Yes, I am 100% sure. Thing is that the script on the bottom needs to find SpeedDemonTrail in serverstorage. It finds the trail and displays the trail behind the player. However the script that enables and disables the trail says "SpeedDemonTrail" is not a valid member... when I click it but the spelling and names its the same ItsJZaid 45 — 4y
0
Well. Not when I click it but when I hit play it displays the trail behind the player, as meant to be. But when I click to disable, nothing happens. I open the script giving the error and says: 19:48:47.753 - SpeedDemonTrail is not a valid member of ServerStorage... However the other script uses the same line to find the trail in server storage and doesn't give the same issue? ItsJZaid 45 — 4y

1 answer

Log in to vote
1
Answered by
Subsz 366 Moderation Voter
4 years ago

Ok, alright so, the problem here is.. that you're trying to access ServerStorage through client.

what you instead want to do is, something like this.

01local player = game.Players.LocalPlayer
02local char = player.Character or player.CharacterAdded:Wait()
03local Debounce = false
04 
05script.Parent.MouseButton1Click:Connect(function()
06    local h = char.Torso.SpeedDemonTrail
07    if Debounce == false then
08        h.Enabled = false
09        script.Parent.Text = ("DemonTrail - OFF")
10        Debounce = true
11    else
12        h.Enabled = true
13        script.Parent.Text = ("DemonTrail - ON")
14        Debounce = false
15    end
16end)
0
OH MY GOD THANK YOU SO MUCH! It works! I really appreciate it! ItsJZaid 45 — 4y
Ad

Answer this question