So what im trying to achieve is giving the morph a proximityprompt that enables the people on the hunters team to catch them.
What currently happens is that everything works perfectly fine, but the proximityprompt just wont show!
Ive tried everything that i know of, lineofsightneeded disabled created a different block way larger then the morph to try and get the proximity prompt to show. All of these just didnt work!
Im hoping someone out here knows the solution to this kinda (weird) problem.
local players = game.Players:GetPlayers()
local teams = game:GetService("Teams")
local model = script.Parent
local prompt = model.Green_Pot_Big_Prompt.ProximityPrompt
local CatchPrompt = model.Green_Pot_Big_Character.Green_Pot_Big.CatchPrompt
prompt.Triggered:Connect(function(player)
print("Prompt has been triggered succesfully!") -- to test if its working
local oldCharacter = player.Character
local newCharacter = model.Green_Pot_Big_Character:Clone()
local CatchPrompt = Instance.new("ProximityPrompt")
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
oldCharacter:Destroy()
newCharacter.Name = player.Name
player.Character = newCharacter
newCharacter.Humanoid.HipHeight = 0.5
newCharacter.Green_Pot_Big.Transparency = 0
newCharacter.Parent = workspace
CatchPrompt.ActionText = "Catch!"
CatchPrompt.RequiresLineOfSight = false
CatchPrompt.HoldDuration = 3
CatchPrompt.Enabled = false
CatchPrompt.Parent = newCharacter.Green_Pot_Big
for i,v in pairs(players) do
if v.Team == teams["Hunters"] then
CatchPrompt.Enabled = true
end
end
end)
I believe if a ProximityPrompt is parented to a model, it will not show the prompt unless you set a primary part for that model.
Or if the part you are parenting the prompt to is big in size, it won’t show the prompt unless you scale it down. In this case, I would create a small, invisible part and position it in front of the morph while also putting the prompt in that part.
The prompt is parented to a BasePart (Part, MeshPart, or Union) or an Attachment. If it’s parented to a model, make sure the model’s primary part is set the in properties window.
The prompt is set to visible (properties window)
I’m not sure how this line of code is meant to work. Is this server code or client code? The rest of your code looks like it’s meant for the server, but changing the prompts on a per player basis should be done on the client.
I can probably figure out what you want your code to do if I know whether this is client or server code.
Additionally, another problem with the lines of code above, the players variable is constant. When you set players to the list of players, it sets players to the current list of players. That means it never changes after the initial set. To fix this, replace
for i,v in pairs(players) do
with
-- I wouldn't make a variable called `players` that isn't the Players service
-- because it's confusing and causes bugs like this.
-- ipairs is better for arrays because it is faster and goes in order (ex: index 1, index 2, etc.)
for i,v in ipairs(game:GetService("Players"):GetChildren()) do
Roblox recommends using game:GetService("Players") instead of game.Players. The Players:GetChildren function is also recommended over Players:GetPlayers.